<?

class Mdl_User_Types extends Model {

    function Mdl_User_Types() {

        parent::Model();

    }

    function get($user_type_id = NULL) {

    // 1 - global administrator
    // this is the god account

    // 2 - site administrator
    // this administrator can perform all administrative functions for the assigned site

    // 3 - global author
    // authors can manage their own posts and pages

    // 4 - site author
    // same as above except only for assigned site

    // 99 - subscriber
    // subscribers can leave comments, etc without having to fill in comment form

        if ($user_type_id) {

            $user_types = $this->user_types();

            return $user_types[$user_type_id]['type'];

        }

        else {

            return $this->user_types();

        }

    }

    function user_types() {

        return array(
        '1'     =>  array('type'=>'Global Administrator','is_global'=>TRUE),
        '2'     =>  array('type'=>'Site Administrator','is_global'=>FALSE),
        '3'     =>  array('type'=>'Global Author','is_global'=>TRUE),
        '4'     =>  array('type'=>'Site Author','is_global'=>FALSE),
        '99'    =>  array('type'=>'Subscriber','is_global'=>FALSE)
        );

    }

    function is_global() {

    // what on earth is this function doing!??!??!

        $user_types = $this->user_types();

        return $user_types[$this->session->userdata['user_type_id']]['is_global'];

    }

    function is_admin($user_type_id) {

        if (is_numeric(array_search($user_type_id, array('1','2','3','4')))) {

            return TRUE;

        }

        else {

            return FALSE;

        }

    }

}

?>